package cn.edu.scau.cmi.lvmingyan.multition;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class MyController implements Initializable {

	@FXML
	private Button button;
	@FXML
	private TextField text;
	@FXML
	private Label result;
	@FXML
	private  TextArea detail;
	
	@Override
	public void initialize(URL location, ResourceBundle resources) {
	}
	
	public void onClick(ActionEvent event) {
		String name = text.getText();
    	if(name == null) {
    		result.setText("No name to create!");
    		return ;
    	}
    	if(Marshal.createMarshal(name)) {
    		result.setText("The marshal is successfully created!");
    		Marshal marshal = Marshal.getMarshal();
        detail.setText(marshal.getName() + marshal.toString());
    	}
    	else {
    		result.setText("The marshal is failed to created!");
    	}
    	
	}

}
